/*
	Gatherer Content Managment System
	Copyright © 2007-2009 by Eric Hokanson
	Last changed on $LastChangedDate: 2007-08-21 16:19:12 -0600 (Tue, 21 Aug 2007) $
	Revision $Revision: 29 $
	Powered by MooTools v1.2
*/

var oldColor, oldOrder;

window.addEvent('domready', function() {
	$('navList').setStyle('cursor', 'default');
	var navSortables = new Sortables('#navList, #conList', {
		constrain: true,
		clone: true,
		onStart: function (e) {
			$('navList').setStyle('cursor', 'move');
			oldOrder = navSortables.serialize().flatten();
			oldColor = e.getStyle('background-color');
			e.setStyle('background-color', 'yellow');
		},
		onComplete: function (e) {
			$('navList').setStyle('cursor', 'default');
			e.setStyle('background-color', oldColor);
			if (!navSortables.serialize().flatten().every(function(item, index) {return item == oldOrder[index];}))
				new Request.JSON({url: 'ajax_dispatcher.php'}).send("mod=gcmsNav&nav=" + navSortables.serialize());
		}
	});
});